# -*- coding: UTF-8 -*-
"""
@Project : Fast
@File    : .py
@IDE     : PyCharm
@Author  : xuan
@Date    : 2023/12/29 11:28
"""
from tortoise import fields
from tortoise.models import Model


class TimestampMixin(Model):
    """
    Models 的基础, 创建时间, 更新时间
    """
    create_time = fields.DatetimeField(auto_now_add=True, description="创建时间")
    update_time = fields.DatetimeField(auto_now=True, description="更新时间")

    class Meta:
        abstract = True


class User(TimestampMixin):
    id = fields.IntField(pk=True, generated=True)
    username = fields.CharField(max_length=100, unique=True)
    password = fields.CharField(max_length=100)
    is_deleted = fields.IntField(default=0)

    def __str__(self):
        return self.username

    class Meta:
        table = "users"
